package com.woniu.bank.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

import java.util.HashSet;

/**
 * @Description: TODO
 * @Author: WangHeng
 * @Date: 2023/1/3 19:15
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {
    @Bean
    public Docket buildDocket() {
        HashSet<String> strings = new HashSet<>();
        strings.add("application/json");
        return (new Docket(DocumentationType.SWAGGER_2)).apiInfo(this.buildApiInfo()).produces(strings).groupName("农贷项目组").select().apis(RequestHandlerSelectors.basePackage("com.woniu.bank.controller")).paths(PathSelectors.any()).build();
    }

    private ApiInfo buildApiInfo() {
        Contact contact = new Contact("Bank", "", "1011945095@qq.com");
        return (new ApiInfoBuilder()).title("农贷项目-平台管理API文档").description("农贷项目-Knife4j文档").contact(contact).version("1.0.0").build();
    }
}
